﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CService.aspx.cs" Inherits="ZF.WS.Admin.service.CService" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<% %>
    <title>在线咨询</title>
    <link href="/css/common.css" rel="stylesheet" type="text/css" />
    <link href="/css/default.css" rel="stylesheet" type="text/css" />
    <link href="/css/default.css" rel="stylesheet" type="text/css" />

    <script src="/js/jQuery.js" type="text/javascript"></script>

    <script src="/js/jquery-1.4.2.js" type="text/javascript"></script>

    <script src="/js/calendar.js" type="text/javascript"></script>

    <script src="/js/index.js" type="text/javascript"></script>

    <script src="/js/jqPlugins/jquery.json-2.2.min.js" type="text/javascript"></script>

    <script src="/js/char.js" type="text/javascript"></script>
   <style>
    .peopleList {width:160px; height:434px }
    .peopleList a{ display:block; line-height:30px; height:30px; text-align:center; font-size:14px; border:1px solid #eee; margin:3px;}
    .peopleList a:hover{ background:#E5F2FB}
    .peopleList dd.active a{background:#0099FF}
    .divTk{ width:500px;height:164px;  }
    
   </style>
</head>
<body>
<script>
    //    setTimeout("setTitle1()", "1000");

    //    function setTitle1() {
    //        document.title = "标题";
    //        window.focus();
    //        setTimeout("setTitle2()", "1000");
    //    }

    //    function setTitle2() {
    //        document.title = "";
    //        setTimeout("setTitle1()", "1000");
    //    }

</script>

    <form id="form1" runat="server">
    <div>
        <div >
            <table class="tabCtn">
                <tr>
                    <td  class="vat_" style="border:1px solid #BCDDF4;">
                        <div class="divTk">
                            <%--<div class="board">
                                <dl>
                                    <dt>
                                        <p>
                                            与<%=this.IsService ? "访客" : "客服"%>进行交谈</p>
                                    </dt>
                                    <dd guid="">
                                        <iframe src="_s.aspx?myguid=<%=this.guid %>&osguid={1}" frameborder="no" border="0"
                                            marginwidth="0" scrolling="no" marginheight="0" allowtransparency="yes" style="border: 0px;
                                            width: 100%; height: 464px;"></iframe>
                                    </dd>
                                </dl>
                            </div>--%>
                        </div>
                        <div class="divTKTemplate dn_">
                            <div class="board" guid="{2}">
                                <dl>
                                    <dt>
                                        <p>
                                            与{0}进行交谈</p>
                                    </dt>
                                    <dd guid="">
                                        <iframe src="_s.aspx?myguid={1}&osguid={2}" guid="{2}" frameborder="no" border="0" marginwidth="0"
                                            scrolling="no" marginheight="0" allowtransparency="yes" style="border: 0px; width: 100%;
                                            height: 464px;"></iframe>
                                    </dd>
                                </dl>
                            </div>
                        </div>
                    </td>
                    <td  class="vat_" >
                        <div class="board peopleList ml5_">
                            <dl>
                                <dt  ><span>当前在线<%=this.IsService ? "访客" : "客服"%>列表</span></dt>
                                <dd>
                                </dd>
                            </dl>
                        </div>
                        <div style="border:1px solid #BCDDF4; height:40px; margin-top:7px;  " class="ml5_" > 
                            <p style="border-bottom:1px solid #BCDDF4; height:30px; line-height:30px; font-size:12px; font-weight:bold;" >&nbsp;&nbsp;当接收到新消息时</p>
                            <input type="checkbox" id="cbFouce"  checked="checked"/><label for="cbFouce">自动激活窗口</label><input type="checkbox" id="cbSound"
                              checked="checked" /><label for="cbFouce">播放声音</label>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <script>
        var guid = "<%=this.guid %>";
        var myguid = guid;
        var osguid = null;
        var asmxPage = "/ServiceChar.asmx"
    </script>
    <div class="divSound">
    
    </div>
    
     
    </form>
</body>
</html>
<% %>

<script>
    var isFocus = false;
    var bAutoFocus = true;
    var bAutoSound = true;
    $("#cbFouce").click(function() {
        bAutoFocus = this.checked; ;
    });
    $("#cbSound").click(function() {
        bAutoSound = this.checked;
    });
    $(window).blur(function() {
        isFocus = false;
    });
    $(window).focus(function() {
        isFocus = true;
        js = 0;
        document.title = title;
    });

    function setTitle1() {
        if (!isFocus) {
            if (bAutoFocus)
                window.focus();
            if (bAutoSound) {
                $(".divSound bgsound").remove();
                $(".divSound").append('<bgsound id="sound_tag" src="/image/dondon.wav"  />');
            }
        }
    }
    window.focus();
    function setTitle2() {
        document.title = "";
        setTimeout("setTitle1()", "1000");
    }
    function _Reced(name) {
        _alert();
        if ($.trim(name) != "" && !isFocus) {
            if (bAutoFocus) {
                window.focus();
            } else if (!isFocus) {
                js = 1;
                _alert();
            }
        }

    }
    var title = ""
    var js = 0;
    function _alert() {
        if (title == "")
            title = document.title;
        if (js % 2 == 0)
            document.title = "                     " + title;
        else
            document.title = "████████████████";
        if (js > 0) {
            js++;
            setTimeout("_alert()", "1000");
        }


    }
     
    
    $(function() {
    window.resizeTo(704, 650);
        setInterval("_keep()", 10000);
        _getPopleList();
        setInterval("_getPopleList()", 1000 * 5);
    });


    function _getPopleList() {

        var cb = function(msg) {

            var __temp = msg;
            var msg = $.evalJSON(msg.d);

            var dl = $(".peopleList dl");
            dl.find("dd").unbind("click");
            dl.find("dd").remove();

            $(msg).each(function() {
                var m = this;


                dl.append(String.format("<dd guid='{1}' name='{0}' ><a href='javascript:' class=''>{0}</a></dd>",
                m.name, m.guid, m.guid == osguid ? "" : ""));
            });

            var divTk = $(".divTk");
            dl.find("dd").click(function() {

                var m = this;
                divTk.find("div").hide().removeClass("active"); ;

                osguid = $(m).attr("guid");
                var name = $(m).attr("name");

                var dd = divTk.find(String.format("div[guid='{0}']", osguid));

                if (dd.length > 0) {
                    var iframe = divTk.find(String.format("div[guid='{0}'] iframe", osguid))[0];
                    dd.show();
                }
                else {
                    var template = $(".divTKTemplate").html();

                    divTk.append(String.format(template, name, myguid, osguid));

                    var iframe = divTk.find(String.format("iframe[guid='{0}']", osguid))[0];

                    iframe.src = iframe.src; ;
                }
                window.document.title = String.format("正在与{0}进行交谈", name);
                title = String.format("正在与{0}进行交谈", name);
            });
            if (osguid == null) {

                var dd = dl.find("dd");
                if (dd.length > 0)
                    dd[0].click();
            }

        };
        var data = $.toJSON({ myGuid: guid });
        ajax(data, "GetOnLineList", cb);
    }
    function _keep() {
        var date = $.toJSON({ guid: guid });
        ajax(date, "Keep", null);
    }
 

</script>

